//
//  OMTAsset.m
//  OMTImagePicker
//
//  Created by yizhaorong on 2017/11/15.
//

#import "OMTAsset.h"
#import "OMTAlbumManager.h"
#import <AVFoundation/AVFoundation.h>
#import <MobileCoreServices/UTCoreTypes.h>

// 照片选中状态改变
NSString *const OMTAssetAssetSelectedStateChangedNotification = @"OMTAssetAssetSelectedStateChangedNotification";
// 照片类型改变
NSString *const OMTAssetAssetTypeChangedNotification = @"OMTAssetAssetTypeChangedNotification";

@implementation OMTAsset

+ (instancetype)asset:(id)asset mediaType:(OMTAssetMediaType)mediaType duration:(NSString *)duration {
    OMTAsset *instance = [self new];
    instance.asset = asset;
    instance.mediaType = mediaType;
    instance.duration = duration;
    return instance;
}

- (void)setAsset:(PHAsset *)asset {
    _asset = asset;
    if (self.isGIF) return;
    if (asset.mediaType != PHAssetMediaTypeImage) return;
    if ([[asset valueForKey:@"filename"] hasSuffix:@"GIF"]) {
        self.GIF = YES;
    }
}

- (void)setSelected:(BOOL)selected {
    _selected = selected;
}

@end
